package com.origin.onlinesys.service.modules.finance.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.origin.onlinesys.common.services.BaseService;
import com.origin.onlinesys.domain.modules.finance.Finance;
import com.origin.onlinesys.domain.modules.interviewsys.InterviewerInfo;
import com.origin.onlinesys.persistence.modules.finance.FinanceMapper;
import com.origin.onlinesys.service.modules.finance.IFinanceService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by origin on 15-3-20.
 * 财务
 */
@Service
public class FinanceServiceImpl extends BaseService<Finance> implements IFinanceService{
    @Override
    public Map selectIncome(int pageNum,int pageSize,String areaId,String incomeStartTime, String incomeEndTime) {
        Map map = new HashMap();
        map.put("incomeStartTime",incomeStartTime);
        map.put("incomeEndTime",incomeEndTime);
        map.put("zoneId",areaId);
        PageHelper.startPage(pageNum, pageSize, true);
        Page<InterviewerInfo> page = (Page)((FinanceMapper)mapper).selectIncome(map);
        Map result = new HashMap();
        result.put("list", page);
        result.put("pageSize", page.getPages());
        result.put("total", page.getTotal());
        return result;
    }

    @Override
    public Map selectPay(int pageNum,int pageSize,String areaId,String payStartTime, String payEndTime) {
        Map map = new HashMap();
        map.put("payStartTime",payStartTime);
        map.put("payEndTime",payEndTime);
        map.put("zoneId",areaId);
        PageHelper.startPage(pageNum, pageSize, true);
        Page<InterviewerInfo> page = (Page)((FinanceMapper)mapper).selectPay(map);
        Map result = new HashMap();
        result.put("list", page);
        result.put("pageSize", page.getPages());
        result.put("total", page.getTotal());
        return result;
    }

    @Override
    public String selectCountFinance(String type,String financeId) {
        Map map = new HashMap();
        map.put("type",type);
        map.put("financeId",financeId);
        return ((FinanceMapper)mapper).selectCountFinance(map);
    }

    @Override
    public int addBatchImg(List<Map> list) {
        ((FinanceMapper)mapper).addBatchImg(list);
        return 1;
    }

    @Override
    public Map selectBalance(String zoneId) {
        return ((FinanceMapper)mapper).selectBalance(zoneId);
    }
}
